﻿$(document).ready(function() {
	$("#txtSearch").keyup(function(event) {
		if (event.keyCode == 13) {
			$("#btnSearch").click();
		}
	}); 
});

function FuncAudio(val){

if(val!=null && val !=""){
	//$("#ifname").hide();
	iframeName="ifname";
	url=val;
	
	if ( window.frames[iframeName] ) {
		window.frames[iframeName].location = url;
		
		//return false;
	}
		//return true; 
		
	$("#ifname").show();
}

}

function FuncClear() {
    $('#txtSearch').val('');
	FuncAudio("white.png");
	$("#ifname").hide();
	
    TableMain = "";
    TableResult = "No Result";
    TablePage = "";

    $("#dicResult").html(TableMain);
    $("#dicShow").html(TableResult);
    $("#dicPageNumber").html(TablePage);
}

function FuncSearch() {
	FuncAudio("white.png");
	$("#ifname").hide();
	 
    var search = $("#txtSearch").val();
    PageCurrentNo = 0;
    SearchMusicKeywordAndPage(search, 0);	
	$("#tdResult").show();
}

function ClickFirst() {
    var search = $("#txtSearch").val();
    SearchMusicKeywordAndPage(search, 0);
}
function ClickLast() {
    var last = (TotalPage - 1) * 10;
    var search = $("#txtSearch").val();

    SearchMusicKeywordAndPage(search, last);
}

function OpenLinkDW(url) {
    window.open(url);
}
function ClickNextPage() {
    var search = $("#txtSearch").val();

    if (PageCurrentNo != TotalPage) {
        PageCurrentNo = PageCurrentNo + 1;
        var Page = PageCurrentNo * 10;

        SearchMusicKeywordAndPage(search, Page);
    } else if (PageCurrentNo == 0) {
        SearchMusicKeywordAndPage(search, 0);
    }
}
function ClickPreviousPage() {
    var search = $("#txtSearch").val();
    if (PageCurrentNo == 0) {

    } else {

        if (PageCurrentNo > 1) {
            PageCurrentNo = PageCurrentNo - 1;
            var Page = (PageCurrentNo * 10) - 10;

            SearchMusicKeywordAndPage(search, Page);
        } else if (PageCurrentNo == 1) {
            curNo = 0;
            SearchMusicKeywordAndPage(search, 0);
        }

    }
}